<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>设置我的资料</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="__PUBLIC__/layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="__PUBLIC__/layuiadmin/style/admin.css" media="all">
</head>

<body>

  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">设置我的资料</div>
          <div class="layui-card-body" pad15>

            <div class="layui-form" lay-filter="">
              <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-inline">
                  <input type="text" value="{$user['user_name']}" readonly class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">不可修改</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">真实姓名</label>
                <div class="layui-input-inline">
                  <input type="text" name="realname" value="{$user['realname']}"
                    autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                  <input type="text" name="mobile" value="{$user['mobile']}" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-inline">
                  <input type="text" name="email" value="{$user['email']}" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <input type="hidden" name="id" value="{$user['id']}">
                  <button class="layui-btn" lay-submit lay-filter="setmyinfo">确认修改</button>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="__PUBLIC__/layuiadmin/layui/layui.js"></script>
  <script>
    layui.config({
      base: '__PUBLIC__/layuiadmin/' //静态资源所在路径
    }).extend({
      index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
      var $ = layui.$
        , layer = layui.layer
        , form = layui.form

      //设置我的资料
      form.on('submit(setmyinfo)', function (obj) {
        // layer.msg(JSON.stringify(obj.field));

        //提交修改
        $.ajax({
          url: "{:U('Admin/Profile/edit')}", 
          type: 'post', 
          data: obj.field, 
          success: function (re) {
            if (re.code == 0) {
              //登入成功的提示与跳转
							layer.msg(re.msg, {
								offset: '15px'
								, icon: 6
								, time: 1000
							}, function () {
								location.reload(); //数据刷新
							});
            } else {
              layer.msg(re.msg, { icon: 5 });
            }
          }
        });
        return false;
      });
    });

  </script>
</body>

</html>